from piercing.pierc_common import CableForceParams
import math
def get_cable_force(params: CableForceParams) -> float:
    # 电缆的单位密度
    rho_cable = (params.cable_mass_per_km / 1000) / (math.pi / 4 * (params.cable_diameter_mm * 0.001) ** 2)
    rho_o1 = rho_cable - params.rho_liud  # 电缆在液体中的单位密度

    # 电缆的截面积
    A_cable = math.pi / 4 * (params.cable_diameter_mm * 0.001) ** 2

    # 电缆在液体中的单位质量
    m_cable = rho_o1 * A_cable

    # 仪器的单位密度
    rho_tool = (params.tool_mass / params.tool_length_m) / (math.pi / 4 * (params.tool_diameter_mm * 0.001) ** 2)
    rho_o2 = rho_tool - params.rho_liud  # 仪器在液体中的单位密度

    # 仪器的截面积
    A_tool = math.pi / 4 * (params.tool_diameter_mm * 0.001) ** 2

    # 仪器在液体中的单位质量
    m_tool = rho_o2 * A_tool

    # 计算电缆在某深度时的拉力
    F_p =((params.well_depth_m - params.tool_length_m) * m_cable * 9.81 + m_tool * params.tool_length_m * 9.81) / 1000
    return F_p
if __name__ == '__main__':
    params = CableForceParams()
    params.rho_liud = 1300
    params.cable_mass_per_km = 508
    params.cable_diameter_mm = 11.8
    params.tool_mass = 300
    params.tool_diameter_mm = 89
    params.tool_length_m = 12
    params.well_depth_m = 4000
    F_p = get_cable_force(params)
    print(F_p)